﻿function ViewPowerUser(objSender, user_id) {
   
    var trDetail = $(objSender).parent().parent().next();
    var tdDetail = $(objSender).parent().parent().next().find("td:eq(0)");

    if (jQuery.trim($(trDetail).css("display")) == "none") {
        $(trDetail).show();
        objSender.src = "../../Images/ImgBody/arrow_up.gif";

        //  var menu_id = $(objSender).parent().find(":hidden:eq(0)").val();
        getDetail(tdDetail, user_id);
    }
    else {
        objSender.src = "../../Images/ImgBody/arrow_down.gif";
        $(trDetail).hide();
    }
    //release ram        
    trDetail = null;
    tdDetail = null;
}

function getDetail(objSender, user_id) {
    
    var objServerVar;
    $(objSender).html("<div style='color:gray;text-align:center'>Loading data, please wait ....<br><img src='../../Images/loading.gif'></div>");
    $.ajax(
		{
		    url: "ctrJs/PowerUser.aspx",
		    type: "post",
		    data: "EventName=getDetail&user_id=" + user_id,
		    dataType: "text",
		    timeout: 100000,
		    error: function (err) {
		        objServerVar = {
		            IsOK: false,
		            ServerMsg: "遠端連線發生錯誤或連線逾時，請再試一次，如果持續發生請連絡相關人員！！"
		        }
		        $(objSender).html("");
		        $(objSender).parent().hide();
		    },
		    success: function (strServerVar) {
		        eval("objServerVar =" + strServerVar);
		    },
		    complete: function () {
		        if (objServerVar.IsOK) {

		            $(objSender).html(objServerVar.Result);
		        } else {
		        }
		    }

		}
	);
}
